#!/usr/local/bin/perl -w
use strict;
use utf8;
use lib '../lib';

use Data::Dumper;
$Data::Dumper::Deparse = 1;

use NG::Sys::App 'NG::Sys::Loop::Run';
use NG::Sys::Cfg;

my $app = new NG::Sys::App(logger => "screen");

$app->run;

sub on_process {
	$app->logger->info("start");
	my $sql = config("reference_install")->{sql};

	my $dbh = $app->dbh_to("one",1);

	for(@$sql){
		print $_,"\n";
		$dbh->exec($_);
	}

	$dbh->commit;
	my $tune = config("reference");
	if($tune->{cache} && $tune->{cache}{fastmmap}){
		my $fn = $tune->{cache}{fastmmap}{filename};
		my $path = $app->{cfg}{path}{cache};
		unlink $path."/".$fn;
		$app->logger->info("unlink $path/$fn");
	}
}
